package cn.javaxc.mvcwork.action.dao;
import java.io.*;
import java.util.*;
import java.sql.*;
import cn.javaxc.model.base.SQL;
import cn.javaxc.model.base.SQLList;
import cn.javaxc.model.base.SQLMap;
import cn.javaxc.model.base.SQLParam;
import cn.javaxc.model.page.BatisPage;
import cn.javaxc.mvcwork.controller.web.TreeBean;
import cn.javaxc.mvcwork.util.common.CommonUtil;
import cn.javaxc.mvcwork.util.common.MapListUtil;
import cn.javaxc.mvcwork.util.helper.FrameHelper;
import cn.javaxc.mvcwork.util.helper.TreeTableHelper;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
import cn.javaxc.mvcwork.controller.*;
import cn.javaxc.mvcwork.mapper.dao.BatisDAOMapper;
public class BatisDAO extends BatisPage
implements cn.javaxc.mvcwork.util.helper.IBaseDAO
{
    @Autowired(required=false)
	private BatisDAOMapper mapper;
    
    
    /**
    查询右菜单类型sql
    */
    
    public SQLList containertype(Map map) {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        params.putAll(map);
        SQLList<SQLMap> listtype=mapper.listtype(params);
        
        return listtype;
    }
    /**
    查询右菜单
    */
    
    public SQLList containermenu(Map map) {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        params.putAll(map);
        SQLList<SQLMap> listmenu=mapper.listmenu(params);
        
        return listmenu;
    }
    /**
    查询右菜单名称sql
    */
    
    public SQLList containername(Map map) {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        params.putAll(map);
        SQLList<SQLMap> listname=mapper.listname(params);
        
        return listname;
    }
    /**
    查询我的桌面sql
    */
    
    public SQLList containerlink(Map map) {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        params.putAll(map);
        SQLList<SQLMap> listlink=mapper.listlink(params);
        
        return listlink;
    }
    /**
    查询我的桌面菜单sql
    */
    
    public SQLList containerlinklist(Map map) {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        params.putAll(map);
        SQLList<SQLMap> linklist=mapper.linklist(params);
        
        return linklist;
    }
    /**
    查询登录用户
    */
    
    public SQLList getuser(String username) {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        params.put("username",username);
        SQLList<SQLMap> listuser=mapper.listuser(params);
        
        return listuser;
    }
    /**
    查询用户密码
    */
    
    public SQLList getuserpassword(String username) {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        params.put("username",username);
        SQLList<SQLMap> listpass=mapper.listpass(params);
        
        return listpass;
    }
    /**
    查询用户菜单
    */
    
    public SQLList getusermenu(Map map) {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        TreeBean tb;
        
        tb = createTreeBean("s_menu_treecols");
        tb.setPrefix("img");
        tb.setTableNodeUrl("url");
        params.putAll(map);
        SQLList<SQLMap> s_menu=mapper.s_menu(params);
        s_menu = s_menu.buildTree(tb,tb.getPid());
        
        return s_menu;
    }
    /**
    查询用户联系人
    */
    
    public SQLList getuserinfo(Object user_id) {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        params.put("user_id",user_id);
        SQLList<SQLMap> listuinfo=mapper.listuinfo(params);
        
        return listuinfo;
    }
    /**
    查询用户权限
    */
    
    public SQLList getuserpermission(int role_id) {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        params.put("role_id",role_id);
        SQLList<SQLMap> listperm=mapper.listperm(params);
        
        return listperm;
    }
    /**
    查询用户联系人
    */
    
    public SQLList getpagetext(String page_id) {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        params.put("page_id",page_id);
        SQLList<SQLMap> listtext=mapper.listtext(params);
        
        return listtext;
    }
    /**
    BatisDAO:查询
    */
    
    public SQLList buildGlobalParams(SystemStatus systemStatus) {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> s_site_cfg=mapper.s_site_cfg(params);
        
        return s_site_cfg;
    }
    /**
    BatisDAO:查询
    */
    
    public SQLList buildSysList(SystemStatus systemStatus) {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> s_sys_info=mapper.s_sys_info(params);
        
        return s_sys_info;
    }
    /**
    增加用户登录记录
    */
    
    public String insertLogRecord(Map map) {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        params.putAll(map);
        mapper.insertLogRecord(params);
        
        return ONSUBMIT;
    }
    /**
    更新文件版本
    */
    
    public String updateFileVersion(Map map) {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        params.putAll(map);
        mapper.updateFileVersion(params);
        
        return ONSUBMIT;
    }
    /**
    增加文件版本
    */
    
    public String insertFileVersion(Map map) {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        params.putAll(map);
        params.def("entered",new Date());
        params.def("modified",new Date());
        mapper.insertFileVersion(params);
        
        return ONSUBMIT;
    }
    /**
    插入文件
    */
    
    public int insertFileItem(Map map) {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        params.putAll(map);
        params.def("entered",new Date());
        int fileid = mapper.fileid(params);
        
        return fileid;
    }
}